package com.example.houduan.demos.web.controller;

import com.example.houduan.demos.web.dto.UserDTO;
import com.example.houduan.demos.web.entity.User;
import com.example.houduan.demos.web.mapper.UserMapper;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/user")
public class UserController {
    @Resource
    private UserMapper userMapper;
    @GetMapping("/getAll")
    public List<User> getAll(){
        return userMapper.findAll();
    }

    @GetMapping("/getSmsCode")
    public User getSmsCode(String phone){
        return userMapper.getSmsCode(phone);
    }

    @PostMapping("/updatePhone")
    public String updatePhone(@RequestBody UserDTO userDTO){

        userMapper.updatePhone(userDTO.getPhone(),userDTO.getCode());
        return "success";
    }
}
